@extends('layouts.auth')

@section('content')
    <div class="am-g ">
        <form class="am-u-sm-12 am-u-md-5 am-u-lg-centered am-padding-lg am-form" id="form-with-tooltip" method="POST"
              action="{{ url('admin/register') }}">
            {!! csrf_field() !!}
            <fieldset>
                <div class="am-form-group{{ $errors->has('name') ? ' am-form-error' : '' }}">
                    <label for="doc-vld-name-2-1">姓名：</label>
                    <input type="text" class="am-radius{{ $errors->has('name') ? ' am-field-error' : '' }}"
                           id="doc-vld-name-2-1" name="text" data-foolish-msg="自定义提示信息：" placeholder="输入姓名" required
                           value="{{ old('name') }}"/>
                    @if ($errors->has('name'))
                        <span class="help-block"><strong>{{ $errors->first('name') }}</strong></span>
                    @endif
                </div>
                <div class="am-form-group{{ $errors->has('email') ? ' am-form-error' : '' }}">
                    <label for="doc-vld-email-2-1">邮箱：</label>
                    <input type="email" class="am-radius{{ $errors->has('email') ? ' am-field-error' : '' }}"
                           id="doc-vld-email-2-1" name="email" data-foolish-msg="自定义提示信息：" placeholder="输入邮箱" required
                           value="{{ old('email') }}"/>
                    @if ($errors->has('email'))
                        <span class="help-block"><strong>{{ $errors->first('email') }}</strong></span>
                    @endif
                </div>
                <div class="am-form-group{{ $errors->has('password') ? ' am-form-error' : '' }}">
                    <label for="doc-vld-pwd-1-0">密码：</label>
                    <input class="am-radius{{ $errors->has('password') ? ' am-field-error' : '' }}" type="password"
                           name="password" id="doc-vld-pwd-1-0" placeholder="请输入密码" pattern="^\w{6}$" required
                           data-foolish-msg="请输入密码"/>
                </div>
                <div class="am-form-group">
                    <label for="doc-vld-pwd-1-0">确认密码：</label>
                    <input class="am-radius" type="password" name="password_confirmation" id="doc-vld-pwd-1-1"
                           placeholder="请输入密码" pattern="^\w{6}$" required data-foolish-msg="请输入密码"/>
                    @if ($errors->has('password_confirmation'))
                        <span class="help-block"><strong>{{ $errors->first('password_confirmation') }}</strong></span>
                    @endif
                </div>
                <input type="hidden" name="name" value="{{ time() }}">
                <div class=" am-u-sm-12 am-margin-bottom-sm">
                    <button type="submit" class="am-btn am-btn-success am-radius am-btn-block">提交</button>
                </div>
            </fieldset>
        </form>
    </div>
@endsection
@section('footer')
    <script language="JavaScript">
        $(function () {
            var $form = $('#form-with-tooltip');
            var $tooltip = $('<div id="vld-tooltip">提示信息！</div>');
            $tooltip.appendTo(document.body);

            $form.validator();

            var validator = $form.data('amui.validator');

            $form.on('focusin focusout', '.am-form-error input', function (e) {
                if (e.type === 'focusin') {
                    var $this = $(this);
                    var offset = $this.offset();
                    var msg = $this.data('foolishMsg') || validator.getValidationMessage($this.data('validity'));

                    $tooltip.text(msg).show().css({
                        left: offset.left + 10,
                        top: offset.top + $(this).outerHeight() + 10
                    });
                } else {
                    $tooltip.hide();
                }
            });
        });
    </script>
@endsection
